﻿using HBase;
using HBase.db;
using hCommand;
using Net.http;
using Persistence;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;

namespace Persistence {
    public class BatchLocAreaEngine : GkTransaction
    {
        public List<long> ids; 
        public long areaId ;

        protected override TransRes Execute()
        { 
            string    sql = "update Core_Wh_Loc set area_Id= @areaId   where id in @ids "; 
            bool res = exec(sql, new { areaId , ids }) == 1; 
            int areaOrder = this.queryUnique<int>(" select  priority from    core_wh_area   where id = @areaId  ", new { areaId }); 
            var cids = query<long>(" select  id  from    Core_Stock    where loc_Id in @ids  ", new { ids }) .ToList();
            if (cids.Count > 0) { 
                exec("update Core_Stock set  area_order =@areaOrder where id in @ids", new { cids, areaOrder });
            } 
            return new TransRes();
        }


       
    }
}
